package com.sf.osms.dep.processor.util;

import org.apache.commons.lang3.StringUtils;

import com.sf.osms.dep.cache.SysConfigCacheHelper;

public class SwitchUtils {
	
	/**
	 * default invoking other system symbol is a string that is "1"
	 */
	private static final String SWITCH = "1";
	
	public static final String FVP_SWITCH_NAME = "fvp.invoke.switch";
	public static final String BSP_SWITCH_NAME = "bsp.invoke.switch";
	public static final String WQS_SWITCH_NAME = "wqs.invoke.switch";
	public static final String EMAIL_SWITCH_NAME = "email.invoke.switch";
	public static final String DEP_TO_FVP_REGISTER = "router.register.invok.switch";
	
	public static boolean getSwithBySystemName(String systemName){
		String systemSwitch = SysConfigCacheHelper.getSysConfigValue(systemName);
		if(StringUtils.isBlank(systemSwitch)){
			return false;
		}else{
			if(SWITCH.equals(systemSwitch.trim())){
				return true;
			}else{
				return false;
			}
		}
		
	}
	
	public static String getNotNullValue(String sysVal,String defaultVal){
		if(StringUtils.isBlank(defaultVal)){
			throw new IllegalArgumentException();
		}
		
		if(StringUtils.isBlank(sysVal)){
			return defaultVal.trim();
		}else{
			return sysVal.trim();
		}
	
	}
	
	public static void main(String[] args) {
		System.out.println(getNotNullValue("  	1","11"));
	}
	
}
